home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume16 / less5 / part01 next >
Encoding:
Internet Message Format  |  1988-09-22  |  56.1 KB

  1. Subject:  v16i030:  Less, a pager that's more than more, Part01/04
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: ctnews!UNIX386!mark
  7. Posting-number: Volume 16, Issue 30
  8. Archive-name: less5/part01
  9.  
  10. Less is a pager, like more or pg, except that it has more features
  11. than either one of them, including the ability to scroll backward
  12. and forward along files and pipes, and to set marks and return to
  13. them like vi and company.
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.
  17. # Remove anything before this line, then unpack it
  18. # by saving it into a file and typing "sh file".
  19.  
  20. echo shar: Extracting \"output.c\"
  21. sed "s/^X//" >'output.c' <<'END_OF_FILE'
  22. X/*
  23. X * High level routines dealing with the output to the screen.
  24. X */
  25. X
  26. X#include "less.h"
  27. X
  28. Xpublic int errmsgs;    /* Count of messages displayed by error() */
  29. X
  30. Xextern int sigs;
  31. Xextern int sc_width, sc_height;
  32. Xextern int ul_width, ue_width;
  33. Xextern int so_width, se_width;
  34. Xextern int bo_width, be_width;
  35. Xextern int tabstop;
  36. Xextern int twiddle;
  37. Xextern int screen_trashed;
  38. Xextern int any_display;
  39. Xextern char *line;
  40. Xextern char *first_cmd;
  41. X
  42. X/*
  43. X * Display the line which is in the line buffer.
  44. X */
  45. X    public void
  46. Xput_line()
  47. X{
  48. X    register char *p;
  49. X    register int c;
  50. X    register int column;
  51. X    extern int auto_wrap, ignaw;
  52. X
  53. X    if (sigs)
  54. X    {
  55. X        /*
  56. X         * Don't output if a signal is pending.
  57. X         */
  58. X        screen_trashed = 1;
  59. X        return;
  60. X    }
  61. X
  62. X    if (line == NULL)
  63. X        line = (twiddle) ? "~" : "";
  64. X
  65. X    column = 0;
  66. X    for (p = line;  *p != '\0';  p++)
  67. X    {
  68. X        switch (c = *p)
  69. X        {
  70. X        case UL_CHAR:
  71. X            ul_enter();
  72. X            column += ul_width;
  73. X            break;
  74. X        case UE_CHAR:
  75. X            ul_exit();
  76. X            column += ue_width;
  77. X            break;
  78. X        case BO_CHAR:
  79. X            bo_enter();
  80. X            column += bo_width;
  81. X            break;
  82. X        case BE_CHAR:
  83. X            bo_exit();
  84. X            column += be_width;
  85. X            break;
  86. X        case '\t':
  87. X            do
  88. X            {
  89. X                putchr(' ');
  90. X                column++;
  91. X            } while ((column % tabstop) != 0);
  92. X            break;
  93. X        case '\b':
  94. X            putbs();
  95. X            column--;
  96. X            break;
  97. X        default:
  98. X            if (c & 0200)
  99. X            {
  100. X                /*
  101. X                 * Control characters arrive here as the
  102. X                 * normal character [carat_char(c)] with
  103. X                 * the 0200 bit set.  See pappend().
  104. X                 */
  105. X                putchr('^');
  106. X                putchr(c & 0177);
  107. X                column += 2;
  108. X            } else
  109. X            {
  110. X                putchr(c);
  111. X                column++;
  112. X            }
  113. X        }
  114. X    }
  115. X    if (column < sc_width || !auto_wrap || ignaw)
  116. X        putchr('\n');
  117. X}
  118. X
  119. X/*
  120. X * Is a given character a "control" character?
  121. X * {{ ASCII DEPENDENT }}
  122. X */
  123. X    public int
  124. Xcontrol_char(c)
  125. X    int c;
  126. X{
  127. X    return (c < ' ' || c == '\177');
  128. X}
  129. X
  130. X/*
  131. X * Return the printable character used to identify a control character
  132. X * (printed after a carat; e.g. '\3' => "^C").
  133. X * {{ ASCII DEPENDENT }}
  134. X */
  135. X    public int
  136. Xcarat_char(c)
  137. X    int c;
  138. X{
  139. X    return ((c == '\177') ? '?' : (c | 0100));
  140. X}
  141. X
  142. X
  143. Xstatic char obuf[1024];
  144. Xstatic char *ob = obuf;
  145. X
  146. X/*
  147. X * Flush buffered output.
  148. X */
  149. X    public void
  150. Xflush()
  151. X{
  152. X    register int n;
  153. X
  154. X    n = ob - obuf;
  155. X    if (n == 0)
  156. X        return;
  157. X    if (write(1, obuf, n) != n)
  158. X        screen_trashed = 1;
  159. X    ob = obuf;
  160. X}
  161. X
  162. X/*
  163. X * Discard buffered output.
  164. X */
  165. X    public void
  166. Xdropout()
  167. X{
  168. X    ob = obuf;
  169. X}
  170. X
  171. X/*
  172. X * Output a character.
  173. X */
  174. X    public void
  175. Xputchr(c)
  176. X    int c;
  177. X{
  178. X    if (ob >= &obuf[sizeof(obuf)])
  179. X        flush();
  180. X    *ob++ = c;
  181. X}
  182. X
  183. X/*
  184. X * Output a string.
  185. X */
  186. X    public void
  187. Xputstr(s)
  188. X    register char *s;
  189. X{
  190. X    while (*s != '\0')
  191. X        putchr(*s++);
  192. X}
  193. X
  194. X/*
  195. X * Output a message in the lower left corner of the screen
  196. X * and wait for carriage return.
  197. X */
  198. X
  199. Xstatic char return_to_continue[] = "  (press RETURN)";
  200. X
  201. X    public void
  202. Xerror(s)
  203. X    char *s;
  204. X{
  205. X    register int c;
  206. X    static char buf[2];
  207. X
  208. X    errmsgs++;
  209. X    if (!any_display)
  210. X    {
  211. X        /*
  212. X         * Nothing has been displayed yet.
  213. X         * Output this message on error output (file
  214. X         * descriptor 2) and don't wait for a keystroke
  215. X         * to continue.
  216. X         *
  217. X         * This has the desirable effect of producing all
  218. X         * error messages on error output if standard output
  219. X         * is directed to a file.  It also does the same if
  220. X         * we never produce any real output; for example, if
  221. X         * the input file(s) cannot be opened.  If we do
  222. X         * eventually produce output, code in edit() makes
  223. X         * sure these messages can be seen before they are
  224. X         * overwritten or scrolled away.
  225. X         */
  226. X        write(2, s, strlen(s));
  227. X        write(2, "\n", 1);
  228. X        return;
  229. X    }
  230. X
  231. X    lower_left();
  232. X    clear_eol();
  233. X    so_enter();
  234. X    putstr(s);
  235. X    putstr(return_to_continue);
  236. X    so_exit();
  237. X
  238. X#if ONLY_RETURN
  239. X    while ((c = getchr()) != '\n' && c != '\r')
  240. X        bell();
  241. X#else
  242. X    c = getchr();
  243. X    if (c != '\n' && c != '\r' && c != ' ' && c != READ_INTR)
  244. X    {
  245. X        buf[0] = c;
  246. X        first_cmd = buf;
  247. X    }
  248. X#endif
  249. X    lower_left();
  250. X
  251. X    if (strlen(s) + sizeof(return_to_continue) + 
  252. X        so_width + se_width + 1 > sc_width)
  253. X        /*
  254. X         * Printing the message has probably scrolled the screen.
  255. X         * {{ Unless the terminal doesn't have auto margins,
  256. X         *    in which case we just hammered on the right margin. }}
  257. X         */
  258. X        repaint();
  259. X
  260. X    flush();
  261. X}
  262. X
  263. Xstatic char intr_to_abort[] = "... (interrupt to abort)";
  264. X
  265. X    public void
  266. Xierror(s)
  267. X    char *s;
  268. X{
  269. X
  270. X    lower_left();
  271. X    clear_eol();
  272. X    so_enter();
  273. X    putstr(s);
  274. X    putstr(intr_to_abort);
  275. X    so_exit();
  276. X    flush();
  277. X}
  278. END_OF_FILE
  279. echo shar: Extracting \"decode.c\"
  280. sed "s/^X//" >'decode.c' <<'END_OF_FILE'
  281. X/*
  282. X * Routines to decode user commands.
  283. X *
  284. X * This is all table driven.
  285. X * A command table is a sequence of command descriptors.
  286. X * Each command descriptor is a sequence of bytes with the following format:
  287. X *    <c1><c2>...<cN><0><action>
  288. X * The characters c1,c2,...,cN are the command string; that is,
  289. X * the characters which the user must type.
  290. X * It is terminated by a null <0> byte.
  291. X * The byte after the null byte is the action code associated
  292. X * with the command string.
  293. X *
  294. X * The default commands are described by cmdtable.
  295. X * User-defined commands are read into usertable.
  296. X */
  297. X
  298. X#include "less.h"
  299. X#include "cmd.h"
  300. X
  301. X/*
  302. X * Command table is ordered roughly according to expected
  303. X * frequency of use, so the common commands are near the beginning.
  304. X */
  305. Xstatic char cmdtable[] =
  306. X{
  307. X    '\r',0,                A_F_LINE,
  308. X    '\n',0,                A_F_LINE,
  309. X    'e',0,                A_F_LINE,
  310. X    'j',0,                A_F_LINE,
  311. X    CONTROL('E'),0,            A_F_LINE,
  312. X    CONTROL('N'),0,            A_F_LINE,
  313. X    'k',0,                A_B_LINE,
  314. X    'y',0,                A_B_LINE,
  315. X    CONTROL('Y'),0,            A_B_LINE,
  316. X    CONTROL('K'),0,            A_B_LINE,
  317. X    CONTROL('P'),0,            A_B_LINE,
  318. X    'd',0,                A_F_SCROLL,
  319. X    CONTROL('D'),0,            A_F_SCROLL,
  320. X    'u',0,                A_B_SCROLL,
  321. X    CONTROL('U'),0,            A_B_SCROLL,
  322. X    ' ',0,                A_F_SCREEN,
  323. X    'f',0,                A_F_SCREEN,
  324. X    CONTROL('F'),0,            A_F_SCREEN,
  325. X    CONTROL('V'),0,            A_F_SCREEN,
  326. X    'b',0,                A_B_SCREEN,
  327. X    CONTROL('B'),0,            A_B_SCREEN,
  328. X    CONTROL('['),'v',0,        A_B_SCREEN,
  329. X    'R',0,                A_FREPAINT,
  330. X    'r',0,                A_REPAINT,
  331. X    CONTROL('R'),0,            A_REPAINT,
  332. X    CONTROL('L'),0,            A_REPAINT,
  333. X    'g',0,                A_GOLINE,
  334. X    '<',0,                A_GOLINE,
  335. X    CONTROL('['),'<',0,        A_GOLINE,
  336. X    'p',0,                A_PERCENT,
  337. X    '%',0,                A_PERCENT,
  338. X    'G',0,                A_GOEND,
  339. X    CONTROL('['),'>',0,        A_GOEND,
  340. X    '>',0,                A_GOEND,
  341. X
  342. X    '0',0,                A_DIGIT,
  343. X    '1',0,                A_DIGIT,
  344. X    '2',0,                A_DIGIT,
  345. X    '3',0,                A_DIGIT,
  346. X    '4',0,                A_DIGIT,
  347. X    '5',0,                A_DIGIT,
  348. X    '6',0,                A_DIGIT,
  349. X    '7',0,                A_DIGIT,
  350. X    '8',0,                A_DIGIT,
  351. X    '9',0,                A_DIGIT,
  352. X
  353. X    '=',0,                A_STAT,
  354. X    CONTROL('G'),0,            A_STAT,
  355. X    '/',0,                A_F_SEARCH,
  356. X    '?',0,                A_B_SEARCH,
  357. X    'n',0,                A_AGAIN_SEARCH,
  358. X    'm',0,                A_SETMARK,
  359. X    '\'',0,                A_GOMARK,
  360. X    CONTROL('X'),CONTROL('X'),0,    A_GOMARK,
  361. X    'E',0,                A_EXAMINE,
  362. X    ':','e',0,            A_EXAMINE,
  363. X    CONTROL('X'),CONTROL('V'),0,    A_EXAMINE,
  364. X    'N',0,                A_NEXT_FILE,
  365. X    'P',0,                A_PREV_FILE,
  366. X    ':','n',0,            A_NEXT_FILE,
  367. X    ':','p',0,            A_PREV_FILE,
  368. X    '-',0,                A_TOGGLE_OPTION,
  369. X    '_',0,                A_DISP_OPTION,
  370. X    'v',0,                A_VISUAL,
  371. X    '!',0,                A_SHELL,
  372. X    '+',0,                A_FIRSTCMD,
  373. X
  374. X    'H',0,                A_HELP,
  375. X    'h',0,                A_HELP,
  376. X    'V',0,                A_VERSION,
  377. X    'q',0,                A_QUIT,
  378. X    ':','q',0,            A_QUIT,
  379. X    'Z','Z',0,            A_QUIT
  380. X};
  381. X
  382. Xchar *cmdendtable = cmdtable + sizeof(cmdtable);
  383. X
  384. Xstatic char usertable[MAX_USERCMD];
  385. Xchar *userendtable = usertable;
  386. X
  387. Xstatic char kbuf[MAX_CMDLEN+1];
  388. Xstatic char *kp = kbuf;
  389. X
  390. X/*
  391. X * Decode a command character and return the associated action.
  392. X */
  393. X    public int
  394. Xcmd_decode(c)
  395. X    int c;
  396. X{
  397. X    register int action = A_INVALID;
  398. X
  399. X    /*
  400. X     * Append the new command character to the command string in kbuf.
  401. X     */
  402. X    *kp++ = c;
  403. X    *kp = '\0';
  404. X
  405. X#if USERFILE
  406. X    /*
  407. X     * Look first for any user-defined commands.
  408. X     */
  409. X    action = cmd_search(usertable, userendtable);
  410. X#endif
  411. X    /*
  412. X     * If didn't find user-defined command,
  413. X     * try the normal default commands.
  414. X     */
  415. X    if (action == A_INVALID)
  416. X        action = cmd_search(cmdtable, cmdendtable);
  417. X
  418. X    if (action != A_PREFIX)
  419. X        /*
  420. X         * This is not a prefix character.
  421. X         */
  422. X        noprefix();
  423. X
  424. X    return (action);
  425. X}
  426. X
  427. X/*
  428. X * Indicate that we're not in a prefix command
  429. X * by resetting the command buffer pointer.
  430. X */
  431. X    public void
  432. Xnoprefix()
  433. X{
  434. X    kp = kbuf;
  435. X}
  436. X
  437. X/*
  438. X * Search a command table for the current command string (in kbuf).
  439. X */
  440. X    static int
  441. Xcmd_search(table, endtable)
  442. X    char *table;
  443. X    char *endtable;
  444. X{
  445. X    register char *p;
  446. X    register char *q;
  447. X
  448. X    for (p = table, q = kbuf;  p < endtable;  p++, q++)
  449. X    {
  450. X        if (*p == *q)
  451. X        {
  452. X            /*
  453. X             * Current characters match.
  454. X             * If we're at the end of the string, we've found it.
  455. X             * Return the action code, which is the character
  456. X             * after the null at the end of the string
  457. X             * in the command table.
  458. X             */
  459. X            if (*p == '\0')
  460. X                return (p[1]);
  461. X        } else if (*q == '\0')
  462. X        {
  463. X            /*
  464. X             * Hit the end of the user's command,
  465. X             * but not the end of the string in the command table.
  466. X             * The user's command is incomplete.
  467. X             */
  468. X            return (A_PREFIX);
  469. X        } else
  470. X        {
  471. X            /*
  472. X             * Not a match.
  473. X             * Skip ahead to the next command in the
  474. X             * command table, and reset the pointer
  475. X             * to the user's command.
  476. X             */
  477. X            while (*p++ != '\0') ;
  478. X            q = kbuf-1;
  479. X        }
  480. X    }
  481. X    /*
  482. X     * No match found in the entire command table.
  483. X     */
  484. X    return (A_INVALID);
  485. X}
  486. X
  487. X/*
  488. X * Initialize the user command table.
  489. X */
  490. X    public void
  491. Xinit_cmd()
  492. X{
  493. X#if USERFILE
  494. X    char *filename;
  495. X    char *homedir;
  496. X    int f;
  497. X    int n;
  498. X    extern char *getenv();
  499. X
  500. X    /*
  501. X     * Try to open "$HOME/.less"
  502. X     * If we can't, return without doing anything.
  503. X     */
  504. X    homedir = getenv("HOME");
  505. X    if (homedir == NULL)
  506. X        return;
  507. X    filename = calloc(strlen(homedir)+7, sizeof(char));
  508. X    if (filename == NULL)
  509. X        return;
  510. X    sprintf(filename, "%s/%s", homedir, ".less");
  511. X    f = open(filename, 0);
  512. X    free(filename);
  513. X    if (f < 0)
  514. X        return;
  515. X
  516. X    /*
  517. X     * Read the file into the user table.
  518. X     * {{ Minimal error checking is done here.
  519. X     *    A garbage .less file will produce strange results.
  520. X     *    To avoid a large amount of error checking code here, we
  521. X     *    rely on the lesskey program to generate a good .less file. }}
  522. X     */
  523. X    n = read(f, (char *)usertable, MAX_USERCMD);
  524. X    if (n < 3 || usertable[n-2] != '\0')
  525. X    {
  526. X        /*
  527. X         * Several error cases are lumped together here:
  528. X         * - Cannot read user file (n < 0).
  529. X         * - User file is too short (a valid file must
  530. X         *   have at least 3 chars: one char command string,
  531. X         *   the terminating null byte, and the action byte).
  532. X         * - The final entry in the user file is bad (it
  533. X         *   doesn't have a null byte in the proper place).
  534. X         * Many other error cases are not caught, such as
  535. X         * invalid format in any except the last entry,
  536. X         * invalid action codes, command strings too long, etc.
  537. X         */
  538. X        error("invalid user key file");
  539. X        n = 0;
  540. X    }
  541. X    userendtable = usertable + n;
  542. X    close(f);
  543. X#endif
  544. X}
  545. END_OF_FILE
  546. echo shar: Extracting \"tags.c\"
  547. sed "s/^X//" >'tags.c' <<'END_OF_FILE'
  548. X#include <stdio.h>
  549. X#include "less.h"
  550. X
  551. X#define    WHITESP(c)    ((c)==' ' || (c)=='\t')
  552. X
  553. X#if TAGS
  554. X
  555. Xpublic char *tagfile;
  556. Xpublic char *tagpattern;
  557. X
  558. Xstatic char *tags = "tags";
  559. X
  560. Xextern int linenums;
  561. Xextern int sigs;
  562. Xextern char *line;
  563. X
  564. X/*
  565. X * Find a tag in the "tags" file.
  566. X * Sets "tagfile" to the name of the file containing the tag,
  567. X * and "tagpattern" to the search pattern which should be used
  568. X * to find the tag.
  569. X */
  570. X    public int
  571. Xfindtag(tag)
  572. X    register char *tag;
  573. X{
  574. X    register char *p;
  575. X    register FILE *f;
  576. X    register int taglen;
  577. X    int search_char;
  578. X    static char tline[200];
  579. X
  580. X    if ((f = fopen(tags, "r")) == NULL)
  581. X    {
  582. X        error("No tags file");
  583. X        tagfile = NULL;
  584. X        return;
  585. X    }
  586. X
  587. X    taglen = strlen(tag);
  588. X
  589. X    /*
  590. X     * Search the tags file for the desired tag.
  591. X     */
  592. X    while (fgets(tline, sizeof(tline), f) != NULL)
  593. X    {
  594. X        if (strncmp(tag, tline, taglen) != 0 || !WHITESP(tline[taglen]))
  595. X            continue;
  596. X
  597. X        /*
  598. X         * Found it.
  599. X         * The line contains the tag, the filename and the
  600. X         * pattern, separated by white space.
  601. X         * The pattern is surrounded by a pair of identical
  602. X         * search characters.
  603. X         * Parse the line and extract these parts.
  604. X         */
  605. X        tagfile = tagpattern = NULL;
  606. X
  607. X        /*
  608. X         * Skip over the whitespace after the tag name.
  609. X         */
  610. X        for (p = tline;  !WHITESP(*p) && *p != '\0';  p++)
  611. X            continue;
  612. X        while (WHITESP(*p))
  613. X            p++;
  614. X        if (*p == '\0')
  615. X            /* File name is missing! */
  616. X            continue;
  617. X
  618. X        /*
  619. X         * Save the file name.
  620. X         * Skip over the whitespace after the file name.
  621. X         */
  622. X        tagfile = p;
  623. X        while (!WHITESP(*p) && *p != '\0')
  624. X            p++;
  625. X        *p++ = '\0';
  626. X        while (WHITESP(*p))
  627. X            p++;
  628. X        if (*p == '\0')
  629. X            /* Pattern is missing! */
  630. X            continue;
  631. X
  632. X        /*
  633. X         * Save the pattern.
  634. X         * Skip to the end of the pattern.
  635. X         * Delete the initial "^" and the final "$" from the pattern.
  636. X         */
  637. X        search_char = *p++;
  638. X        if (*p == '^')
  639. X            p++;
  640. X        tagpattern = p;
  641. X        while (*p != search_char && *p != '\0')
  642. X            p++;
  643. X        if (p[-1] == '$')
  644. X            p--;
  645. X        *p = '\0';
  646. X
  647. X        fclose(f);
  648. X        return;
  649. X    }
  650. X    fclose(f);
  651. X    error("No such tag in tags file");
  652. X    tagfile = NULL;
  653. X}
  654. X
  655. X/*
  656. X * Search for a tag.
  657. X * This is a stripped-down version of search().
  658. X * We don't use search() for several reasons:
  659. X *   -    We don't want to blow away any search string we may have saved.
  660. X *   -    The various regular-expression functions (from different systems:
  661. X *    regcmp vs. re_comp) behave differently in the presence of 
  662. X *    parentheses (which are almost always found in a tag).
  663. X */
  664. X    public int
  665. Xtagsearch()
  666. X{
  667. X    POSITION pos, linepos;
  668. X    int linenum;
  669. X
  670. X    pos = (POSITION)0;
  671. X    linenum = find_linenum(pos);
  672. X
  673. X    for (;;)
  674. X    {
  675. X        /*
  676. X         * Get lines until we find a matching one or 
  677. X         * until we hit end-of-file.
  678. X         */
  679. X        if (sigs)
  680. X            return (1);
  681. X
  682. X        /*
  683. X         * Read the next line, and save the 
  684. X         * starting position of that line in linepos.
  685. X         */
  686. X        linepos = pos;
  687. X        pos = forw_raw_line(pos);
  688. X        if (linenum != 0)
  689. X            linenum++;
  690. X
  691. X        if (pos == NULL_POSITION)
  692. X        {
  693. X            /*
  694. X             * We hit EOF without a match.
  695. X             */
  696. X            error("Tag not found");
  697. X            return (1);
  698. X        }
  699. X
  700. X        /*
  701. X         * If we're using line numbers, we might as well
  702. X         * remember the information we have now (the position
  703. X         * and line number of the current line).
  704. X         */
  705. X        if (linenums)
  706. X            add_lnum(linenum, pos);
  707. X
  708. X        /*
  709. X         * Test the line to see if we have a match.
  710. X         */
  711. X        if (strcmp(tagpattern, line) == 0)
  712. X            break;
  713. X    }
  714. X
  715. X    jump_loc(linepos);
  716. X    return (0);
  717. X}
  718. X
  719. X#endif
  720. END_OF_FILE
  721. echo shar: Extracting \"version.c\"
  722. sed "s/^X//" >'version.c' <<'END_OF_FILE'
  723. X/*
  724. X *        less
  725. X *    Copyright (c) 1984,1985  Mark Nudelman
  726. X *
  727. X *    This program may be freely used and/or modified, 
  728. X *    with the following provisions:
  729. X *    1. This notice and the above copyright notice must remain intact.
  730. X *    2. Neither this program, nor any modification of it,
  731. X *       may be sold for profit without written consent of the author.
  732. X *
  733. X *    -----------------------------------------------------------------
  734. X *
  735. X *    This program is a paginator similar to "more", 
  736. X *    but allows you to move both forward and backward in the file.  
  737. X *    Commands are based on "more" and "vi".
  738. X *
  739. X *    ----------------------- CHANGES ---------------------------------
  740. X *
  741. X *        Allowed use on standard input        1/29/84   markn
  742. X *        Added E, N, P commands            2/1/84    markn
  743. X *        Added '=' command, 'stop' signal handling    4/17/84   markn
  744. X *        Added line folding                4/20/84   markn
  745. X *    v2: Fixed '=' command to use BOTTOM_PLUS_ONE, 
  746. X *        instead of TOP, added 'p' & 'v' commands    4/27/84   markn
  747. X *    v3: Added -m and -t options, '-' command    5/3/84    markn
  748. X *    v4: Added LESS environment variable        5/3/84    markn
  749. X *    v5: New comments, fixed '-' command slightly    5/3/84    markn
  750. X *    v6: Added -Q, visual bell            5/15/84   markn
  751. X *    v7: Fixed jump_back(n) bug: n should count real
  752. X *        lines, not folded lines.  Also allow number
  753. X *        on G command.                5/24/84   markn
  754. X *    v8: Re-do -q and -Q commands            5/30/84   markn
  755. X *    v9: Added "+<cmd>" argument            9/25/84   markn
  756. X *    v10: Fixed bug in -b<n> argument processing    10/10/84  markn
  757. X *    v11: Made error() ring bell if \n not entered.    10/18/84  markn
  758. X *    -----------------------------------------------------------------
  759. X *    v12: Reorganized signal handling and made
  760. X *         portable to 4.2bsd.            2/13/85   mark
  761. X *    v13: Reword error message for '-' command.    2/16/85   mark
  762. X *    v14: Added -bf and -bp variants of -b.        2/22/85   mark
  763. X *    v15: Miscellaneous changes.            2/25/85   mark
  764. X *    v16: Added -u flag for backspace processing.    3/13/85   mark
  765. X *    v17: Added j and k commands, 
  766. X *        changed -t default.            4/13/85   mark
  767. X *    v18: Rewrote signal handling code.        4/20/85   mark
  768. X *    v19: Got rid of "verbose" eq_message().        5/2/85    mark
  769. X *         Made search() scroll in some cases.
  770. X *    v20: Fixed screen.c ioctls for System V.    5/21/85   mark
  771. X *    v21: Fixed some first_cmd bugs.            5/23/85   mark
  772. X *    v22: Added support for no RECOMP nor REGCMP.    5/24/85   mark
  773. X *     v23: Miscellanous changes and prettying up.    5/25/85   mark
  774. X *        Posted to USENET.
  775. X *    -----------------------------------------------------------------
  776. X *      v24: Added ti,te terminal init & de-init       6/3/85 Mike Kersenbrock
  777. X *    v25: Added -U flag, standout mode underlining.    6/8/85    mark
  778. X *    v26: Added -M flag.                6/9/85    mark
  779. X *         Use underline termcap (us) if it exists.
  780. X *    v27: Renamed some variables to make unique in    6/15/85   mark
  781. X *         6 chars.  Minor fix to -m.
  782. X *    v28: Fixed right margin bug.            6/28/85   mark
  783. X *    v29: Incorporated M.Rose's changes to signal.c    6/28/85   mark
  784. X *    v30: Fixed stupid bug in argument processing.    6/29/85   mark
  785. X *    v31: Added -p flag, changed repaint algorithm.  7/15/85   mark
  786. X *         Added kludge for magic cookie terminals.
  787. X *    v32: Added cat_file if output not a tty.    7/16/85   mark
  788. X *    v33: Added -e flag and EDITOR.            7/23/85   mark
  789. X *    v34: Added -s flag.                7/26/85   mark
  790. X *    v35: Rewrote option handling; added option.c.    7/27/85   mark
  791. X *    v36: Fixed -e flag to work if not last file.    7/29/85   mark
  792. X *    v37: Added -x flag.                8/10/85   mark
  793. X *    v38: Changed prompting; created prompt.c.    8/19/85   mark
  794. X *    v39: (Not -p) does not initially clear screen.    8/24/85   mark
  795. X *    v40: Added "skipping" indicator in forw().    8/26/85   mark
  796. X *        Posted to USENET.
  797. X *    -----------------------------------------------------------------
  798. X *    v41: ONLY_RETURN, control char commands,    9/17/85   mark
  799. X *         faster search, other minor fixes.
  800. X *    v42: Added ++ command line syntax;        9/25/85   mark
  801. X *         ch_fsize for pipes.
  802. X *    v43: Added -h flag, changed prim.c algorithms.    10/15/85  mark
  803. X *    v44: Made END print in all cases of eof;    10/16/85  mark
  804. X *         ignore SIGTTOU after receiving SIGTSTP.
  805. X *    v45: Never print backspaces unless -u.        10/16/85  mark
  806. X *    v46: Backwards scroll in jump_loc.        10/24/85  mark
  807. X *    v47: Fixed bug in edit(): *first_cmd==0        10/30/85  mark
  808. X *    v48: Use TIOCSETN instead of TIOCSETP.        11/16/85  mark
  809. X *         Added marks (m and ' commands).
  810. X *        Posted to USENET.
  811. X *    -----------------------------------------------------------------
  812. X *    v49: Fixed bug: signal didn't clear mcc.    1/9/86    mark
  813. X *    v50: Added ' (quote) to gomark.            1/15/86   mark
  814. X *    v51: Added + cmd, fixed problem if first_cmd
  815. X *         fails, made g cmd sort of "work" on pipes
  816. X *         even if bof is no longer buffered.        1/16/86   mark
  817. X *    v52: Made short files work better.        1/17/86   mark
  818. X *    v53: Added -P option.                1/20/86   mark
  819. X *    v54: Changed help to use HELPFILE.        1/20/86   mark
  820. X *    v55: Messages work better if not tty output.    1/23/86   mark
  821. X *    v56: Added -l option.                1/24/86   mark
  822. X *    v57: Fixed -l to get confirmation before
  823. X *         overwriting an existing file.        1/31/86   mark
  824. X *    v58: Added filename globbing.            8/28/86   mark
  825. X *    v59: Fixed some bugs with very long filenames.    9/15/86   mark
  826. X *    v60: Incorporated changes from Leith (Casey)
  827. X *         Leedom for boldface and -z option.        9/26/86   mark
  828. X *    v61: Got rid of annoying repaints after ! cmd.    9/26/86   mark
  829. X *        Posted to USENET.
  830. X *    -----------------------------------------------------------------
  831. X *    v62: Added is_directory(); change -z default to
  832. X *         -1 instead of 24; cat-and-exit if -e and
  833. X *         file is less than a screenful.        12/23/86  mark
  834. X *    v63: Fixed bug in cat-and-exit if > 1 file.    1/8/87    mark
  835. X *    v64: Changed puts/putstr, putc/putchr, 
  836. X *         getc/getchr to avoid name conflict with 
  837. X *         stdio functions.                1/12/87  mark
  838. X *    v65: Allowed '-' command to change NUMBER
  839. X *         valued options (thanks to Gary Puckering)    1/26/87  mark
  840. X *    v66: Fixed bug: prepaint should use force=1.    2/13/87  mark
  841. X *    v67: Added !! and % expansion to ! command.    2/24/87  mark
  842. X *    v68: Added SIGWINCH and TIOCGWINSZ support;
  843. X *         changed is_directory to bad_file.
  844. X *         (thanks to J. Robert Ward)            2/25/87  mark
  845. X *    v69: Added SIGWIND and WIOCGETD (for Unix PC).    2/25/87  mark
  846. X *    v70: Changed help cmd from 'h' to 'H'; better 
  847. X *         error msgs in bad_file, errno_message.    3/13/87  mark
  848. X *    v71: Changed -p to -c, made triple -c/-C
  849. X *         for clear-eol like more's -c.        5/11/87  mark
  850. X *    v72: Added -E, -L, use $SHELL in lsystem().    6/26/87  mark
  851. X *         (thanks to Steve Spearman)
  852. X *    v73: Allow Examine "#" for previous file.    6/26/87  mark
  853. X *        Posted to USENET 8/25/87.
  854. X *    -----------------------------------------------------------------
  855. X *    v74: Fix conflict in EOF symbol with stdio.h,    9/18/87  mark
  856. X *         Make os.c more portable to BSD.
  857. X *    v75: Fix problems in get_term (thanks to     9/23/87  mark
  858. X *         Paul Eggert); new backwards scrolling in
  859. X *         jump_loc (thanks to Marion Hakanson).
  860. X *    v76: Added -i flag; allow single "!" to        9/23/87  mark
  861. X *         invoke a shell (thanks to Franco Barber).
  862. X *    v77: Added -n flag and line number support.    9/24/87  mark
  863. X *    v78: Fixed problem with prompts longer than    9/25/87  mark
  864. X *         the screen width.    
  865. X *    v79: Added the _ command.            9/29/87  mark
  866. X *    v80: Allow signal to break out of linenum scan.    10/6/87  mark
  867. X *    v81: Allow -b to be changed from within less.    10/6/87  mark
  868. X *    v82: Add cmd_decode to use a table for key    10/7/87  mark
  869. X *         binding (thanks to David Nason).
  870. X *    v83: Allow .less file for user-defined keys.    10/9/87  mark
  871. X *    v84: Fix -e/-E problems (thanks to Felix Lee).    10/11/87 mark
  872. X *    v85: Search now keeps track of line numbers.    10/15/87 mark
  873. X *    v86: Added -B option and autobuf; fixed        10/20/87 mark
  874. X *         "pipe error" bug.
  875. X *    v87: Fix bug re BSD signals while reading file.    3/1/88   mark
  876. X *    v88: Use new format for -P option (thanks to    3/12/88  mark
  877. X *         der Mouse), allow "+-c" without message,
  878. X *         fix bug re BSD hangup.
  879. X *    v89: Turn off line numbers if linenum scan    3/18/88  mark
  880. X *         is interrupted.
  881. X *    v90: Allow -P from within less.            3/30/88  mark
  882. X *    v91: Added tags file support (new -t option)    3/30/88  mark
  883. X *         (thanks to Brian Campbell).
  884. X *    v92: Added -+option syntax.            4/4/88   mark
  885. X *    v93: Add support for slow input (thanks to    4/11/88  mark
  886. X *         Joe Orost & apologies for taking almost
  887. X *         3 years to get this in!)
  888. X *    v94: Redo reading/signal stuff.            4/11/88  mark
  889. X *    v95: Repaint screen better after signal.    4/20/88  mark
  890. X *    v96: Add /! and ?! commands.            4/21/88  mark
  891. X *    v97: Allow -l/-L from within less.        5/17/88  mark
  892. X *         Eliminate some static arrays (use calloc).
  893. X */
  894. X
  895. Xchar version[] = "@(#) less  version 97";
  896. END_OF_FILE
  897. echo shar: Extracting \"less.man\"
  898. sed "s/^X//" >'less.man' <<'END_OF_FILE'
  899. X
  900. X
  901. X
  902. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  903. X
  904. X
  905. X
  906. X     NNNNAAAAMMMMEEEE
  907. X          less - opposite of more
  908. X
  909. X     SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  910. X          lllleeeessssssss [[[[----[[[[++++]]]]aaaaAAAABBBBccccCCCCddddeeeeEEEEiiiimmmmMMMMnnnnqqqqQQQQuuuuUUUUsssswwww]]]] [[[[----bbbb_N]]]] [[[[----hhhh_N]]]] [[[[----xxxx_N]]]] [[[[----[[[[zzzz]]]]_N]]]]
  911. X               [[[[----PPPP[[[[mmmmMMMM====]]]]_s_t_r_i_n_g]]]] [[[[----[[[[llllLLLL]]]]_l_o_g_f_i_l_e]]]] [[[[++++_c_m_d]]]]
  912. X               [[[[----tttt_t_a_g]]]] [[[[_f_i_l_e_n_a_m_e]]]]............
  913. X
  914. X     DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  915. X          _L_e_s_s is a program similar to _m_o_r_e (1), but which allows
  916. X          backwards movement in the file as well as forward movement.
  917. X          Also, _l_e_s_s does not have to read the entire input file
  918. X          before starting, so with large input files it starts up
  919. X          faster than text editors like _v_i (1).  _L_e_s_s uses termcap (or
  920. X          terminfo on some systems), so it can run on a variety of
  921. X          terminals.  There is even limited support for hardcopy
  922. X          terminals.  (On a hardcopy terminal, lines which should be
  923. X          printed at the top of the screen are prefixed with an up-
  924. X          arrow.)
  925. X
  926. X          Commands are based on both _m_o_r_e and _v_i. Commands may be
  927. X          preceeded by a decimal number, called N in the descriptions
  928. X          below.  The number is used by some commands, as indicated.
  929. X
  930. X
  931. X     CCCCOOOOMMMMMMMMAAAANNNNDDDDSSSS
  932. X          In the following descriptions, ^X means control-X.  ESC
  933. X          stands for the ESCAPE key; for example ESC-v means the two
  934. X          character sequence "ESCAPE", then "v".
  935. X
  936. X          H    Help: display a summary of these commands.  If you
  937. X               forget all the other commands, remember this one.
  938. X
  939. X          SPACE or f or ^F or ^V
  940. X               Scroll forward N lines, default one window (see option
  941. X               -z below).  If N is more than the screen size, only the
  942. X               final screenful is displayed.  Warning: some systems
  943. X               use ^V as a special literalization character.
  944. X
  945. X          b or ^B or ESC-v
  946. X               Scroll backward N lines, default one window (see option
  947. X               -z below).  If N is more than the screen size, only the
  948. X               final screenful is displayed.
  949. X
  950. X          RETURN or ^N or e or ^E or j or ^J
  951. X               Scroll forward N lines, default 1.  The entire N lines
  952. X               are displayed, even if N is more than the screen size.
  953. X
  954. X          y or ^Y or ^P or k or ^K
  955. X               Scroll backward N lines, default 1.  The entire N lines
  956. X               are displayed, even if N is more than the screen size.
  957. X               Warning: some systems use ^Y as a special job control
  958. X
  959. X
  960. X
  961. X     Page 1                                          (printed 7/19/88)
  962. X
  963. X
  964. X
  965. X
  966. X
  967. X
  968. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  969. X
  970. X
  971. X
  972. X               character.
  973. X
  974. X          d or ^D
  975. X               Scroll forward N lines, default one half of the screen
  976. X               size.  If N is specified, it becomes the new default
  977. X               for subsequent d and u commands.
  978. X
  979. X          u or ^U
  980. X               Scroll backward N lines, default one half of the screen
  981. X               size.  If N is specified, it becomes the new default
  982. X               for subsequent d and u commands.
  983. X
  984. X          r or ^R or ^L
  985. X               Repaint the screen.
  986. X
  987. X          R    Repaint the screen, discarding any buffered input.
  988. X               Useful if the file is changing while it is being
  989. X               viewed.
  990. X
  991. X          g or < or ESC-<
  992. X               Go to line N in the file, default 1 (beginning of
  993. X               file).  (Warning: this may be slow if N is large.)
  994. X
  995. X          G or > or ESC->
  996. X               Go to line N in the file, default the end of the file.
  997. X               (Warning: this may be slow if N is large, or if N is
  998. X               not specified and standard input, rather than a file,
  999. X               is being read.)
  1000. X
  1001. X          p or %
  1002. X               Go to a position N percent into the file.  N should be
  1003. X               between 0 and 100.  (This works if standard input is
  1004. X               being read, but only if _l_e_s_s has already read to the
  1005. X               end of the file.  It is always fast, but not always
  1006. X               useful.)
  1007. X
  1008. X          m    Followed by any lowercase letter, marks the current
  1009. X               position with that letter.
  1010. X
  1011. X          '    (Single quote.) Followed by any lowercase letter,
  1012. X               returns to the position which was previously marked
  1013. X               with that letter.  Followed by another single quote,
  1014. X               returns to the postion at which the last "large"
  1015. X               movement command was executed.  All marks are lost when
  1016. X               a new file is examined.
  1017. X
  1018. X          ^X^X Same as single quote.
  1019. X
  1020. X          /pattern
  1021. X               Search forward in the file for the N-th line containing
  1022. X               the pattern.  N defaults to 1.  The pattern is a
  1023. X               regular expression, as recognized by _e_d. The search
  1024. X
  1025. X
  1026. X
  1027. X     Page 2                                          (printed 7/19/88)
  1028. X
  1029. X
  1030. X
  1031. X
  1032. X
  1033. X
  1034. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  1035. X
  1036. X
  1037. X
  1038. X               starts at the second line displayed (but see the -a
  1039. X               option, which changes this).
  1040. X
  1041. X          ?pattern
  1042. X               Search backward in the file for the N-th line
  1043. X               containing the pattern.  The search starts at the line
  1044. X               immediately before the top line displayed.
  1045. X
  1046. X          /!pattern
  1047. X               Like /, but the search is for the N-th line which does
  1048. X               NOT contain the pattern.
  1049. X
  1050. X          ?!pattern
  1051. X               Like ?, but the search is for the N-th line which does
  1052. X               NOT contain the pattern.
  1053. X
  1054. X          n    Repeat previous search, for N-th line containing the
  1055. X               last pattern (or NOT containing the last pattern, if
  1056. X               the previous search was /! or ?!).
  1057. X
  1058. X          E [filename]
  1059. X               Examine a new file.  If the filename is missing, the
  1060. X               "current" file (see the N and P commands below) from
  1061. X               the list of files in the command line is re-examined.
  1062. X               If the filename is a pound sign (#), the previously
  1063. X               examined file is re-examined.
  1064. X
  1065. X          ^X^V or :e
  1066. X               Same as E.  Warning: some systems use ^V as a special
  1067. X               literalization character.
  1068. X
  1069. X          N or :n
  1070. X               Examine the next file (from the list of files given in
  1071. X               the command line).  If a number N is specified (not to
  1072. X               be confused with the command N), the N-th next file is
  1073. X               examined.
  1074. X
  1075. X          P or :p
  1076. X               Examine the previous file.  If a number N is specified,
  1077. X               the N-th previous file is examined.
  1078. X
  1079. X          = or ^G
  1080. X               Prints some information about the file being viewed,
  1081. X               including its name and the line number and byte offset
  1082. X               of the bottom line being displayed.  If possible, it
  1083. X               also prints the length of the file and the percent of
  1084. X               the file above the last displayed line.
  1085. X
  1086. X          -    Followed by one of the command line option letters (see
  1087. X               below), this will change the setting of that option and
  1088. X               print a message describing the new setting.  If the
  1089. X               option letter has a numeric value (such as -b or -h),
  1090. X
  1091. X
  1092. X
  1093. X     Page 3                                          (printed 7/19/88)
  1094. X
  1095. X
  1096. X
  1097. X
  1098. X
  1099. X
  1100. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  1101. X
  1102. X
  1103. X
  1104. X               or a string value (such as -P or -t), a new value may
  1105. X               be entered after the option letter.
  1106. X
  1107. X          _    (Underscore.) Followed by one of the command line
  1108. X               option letters (see below), this will print a message
  1109. X               describing the current setting of that option.  The
  1110. X               setting of the option is not changed.
  1111. X
  1112. X          +cmd Causes the specified cmd to be executed each time a new
  1113. X               file is examined.  For example, +G causes _l_e_s_s to
  1114. X               initially display each file starting at the end rather
  1115. X               than the beginning.
  1116. X
  1117. X          V    Prints the version number of _l_e_s_s being run.
  1118. X
  1119. X          q or :q or ZZ
  1120. X               Exits _l_e_s_s.
  1121. X
  1122. X          The following two commands may or may not be valid,
  1123. X          depending on your particular installation.
  1124. X
  1125. X          v    Invokes an editor to edit the current file being
  1126. X               viewed.  The editor is taken from the environment
  1127. X               variable EDITOR, or defaults to "vi".
  1128. X
  1129. X          ! shell-command
  1130. X               Invokes a shell to run the shell-command given.  A
  1131. X               percent sign in the command is replaced by the name of
  1132. X               the current file.  "!!" repeats the last shell command.
  1133. X               "!" with no shell command simply invokes a shell.  In
  1134. X               all cases, the shell is taken from the environment
  1135. X               variable SHELL, or defaults to "sh".
  1136. X
  1137. X     OOOOPPPPTTTTIIIIOOOONNNNSSSS
  1138. X          Command line options are described below.  Most options may
  1139. X          be changed while _l_e_s_s is running, via the "-" command.
  1140. X
  1141. X          Options are also taken from the environment variable "LESS".
  1142. X          For example, to avoid typing "less -options ..." each time
  1143. X          _l_e_s_s is invoked, you might tell _c_s_h:
  1144. X
  1145. X          setenv LESS "-options"
  1146. X
  1147. X          or if you use _s_h:
  1148. X
  1149. X          LESS="-options"; export LESS
  1150. X
  1151. X          The environment variable is parsed before the command line,
  1152. X          so command line options override the LESS environment
  1153. X          variable.  If an option appears in the LESS variable, it can
  1154. X          be reset to its default on the command line by beginning the
  1155. X          command line option with "-+".
  1156. X
  1157. X
  1158. X
  1159. X     Page 4                                          (printed 7/19/88)
  1160. X
  1161. X
  1162. X
  1163. X
  1164. X
  1165. X
  1166. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  1167. X
  1168. X
  1169. X
  1170. X          A dollar sign ($) may be used to signal the end of an option
  1171. X          string.  This is important only for options like -P which
  1172. X          take a following string.
  1173. X
  1174. X          -a   Normally, forward searches start just after the top
  1175. X               displayed line (that is, at the second displayed line).
  1176. X               Thus, forward searches include the currently displayed
  1177. X               screen.  The -a option causes forward searches to start
  1178. X               just after the bottom line displayed, thus skipping the
  1179. X               currently displayed screen.
  1180. X
  1181. X          -A   The -A option causes searches to start at the second
  1182. X               SCREEN line displayed, as opposed to the default which
  1183. X               is to start at the second REAL line displayed.  For
  1184. X               example, suppose a long real line occupies the first
  1185. X               three screen lines.  The default search will start at
  1186. X               the second real line (the fourth screen line), while
  1187. X               the -A option will cause the search to start at the
  1188. X               second screen line (in the midst of the first real
  1189. X               line).  (This option is rarely useful.)
  1190. X
  1191. X          -b   The -b_n option tells _l_e_s_s to use a non-standard number
  1192. X               of buffers.  Buffers are 1K, and normally 10 buffers
  1193. X               are used (except if data in coming from standard input;
  1194. X               see the -B option).  The number _n specifies a different
  1195. X               number of buffers to use.
  1196. X
  1197. X          -B   Normally, when data is coming from standard input,
  1198. X               buffers are allocated automatically as needed, to avoid
  1199. X               loss of data.  The -B option disables this feature, so
  1200. X               that only the default number of buffers are used.  If
  1201. X               more data is read than will fit in the buffers, the
  1202. X               oldest data is discarded.
  1203. X
  1204. X          -c   Normally, _l_e_s_s will repaint the screen by scrolling
  1205. X               from the bottom of the screen.  If the -c option is
  1206. X               set, when _l_e_s_s needs to change the entire display, it
  1207. X               will paint from the top line down.
  1208. X
  1209. X          -C   The -C option is like -c, but the screen is cleared
  1210. X               before it is repainted.
  1211. X
  1212. X          -d   Normally, _l_e_s_s will complain if the terminal is dumb;
  1213. X               that is, lacks some important capability, such as the
  1214. X               ability to clear the screen or scroll backwards.  The
  1215. X               -d option suppresses this complaint (but does not
  1216. X               otherwise change the behavior of the program on a dumb
  1217. X               terminal).
  1218. X
  1219. X          -e   Normally the only way to exit less is via the "q"
  1220. X               command.  The -e option tells less to automatically
  1221. X               exit the second time it reaches end-of-file.
  1222. X
  1223. X
  1224. X
  1225. X     Page 5                                          (printed 7/19/88)
  1226. X
  1227. X
  1228. X
  1229. X
  1230. X
  1231. X
  1232. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  1233. X
  1234. X
  1235. X
  1236. X          -E   The -E flag causes less to exit the first time it
  1237. X               reaches end-of-file.
  1238. X
  1239. X          -h   Normally, _l_e_s_s will scroll backwards when backwards
  1240. X               movement is necessary.  The -h option specifies a
  1241. X               maximum number of lines to scroll backwards.  If it is
  1242. X               necessary to move backwards more than this many lines,
  1243. X               the screen is repainted in a forward direction.  (If
  1244. X               the terminal does not have the ability to scroll
  1245. X               backwards, -h0 is implied.)
  1246. X
  1247. X          -i   The -i option causes searches to ignore case; that is,
  1248. X               uppercase and lowercase are considered identical.
  1249. X               Also, text which is overstruck or underlined can be
  1250. X               searched for.
  1251. X
  1252. X          -l   The -l option, followed immediately by a filename, will
  1253. X               cause _l_e_s_s to copy its input to the named file as it is
  1254. X               being viewed.  This applies only when the input file is
  1255. X               a pipe, not an ordinary file.  If the file already
  1256. X               exists, less will ask for confirmation before
  1257. X               overwriting it.
  1258. X
  1259. X          -L   The -L option is like -l, but it will overwrite an
  1260. X               existing file without asking for confirmation.
  1261. X
  1262. X               If no log file has been specified, the -l and -L
  1263. X               options can be used from within less to specify a log
  1264. X               file.  Without a file name, they will simply report the
  1265. X               name of the log file.
  1266. X
  1267. X          -m   Normally, _l_e_s_s prompts with a colon.  The -m option
  1268. X               causes _l_e_s_s to prompt verbosely (like _m_o_r_e), with the
  1269. X               percent into the file.
  1270. X
  1271. X          -M   The -M option causes _l_e_s_s to prompt even more verbosely
  1272. X               than _m_o_r_e.
  1273. X
  1274. X          -n   The -n flag suppresses line numbers.  The default (to
  1275. X               use line numbers) may cause _l_e_s_s to run more slowly in
  1276. X               some cases, especially with a very large input file.
  1277. X               Suppressing line numbers with the -n flag will avoid
  1278. X               this problem.  Using line numbers means: the line
  1279. X               number will be displayed in the verbose prompt and in
  1280. X               the = command, and the v command will pass the current
  1281. X               line number to the editor.
  1282. X
  1283. X          -P   The -P option provides a way to tailor the three prompt
  1284. X               styles to your own preference.  You would normally put
  1285. X               this option in your LESS environment variable, rather
  1286. X               than type it in with each less command.  Such an option
  1287. X               must either be the last option in the LESS variable, or
  1288. X
  1289. X
  1290. X
  1291. X     Page 6                                          (printed 7/19/88)
  1292. X
  1293. X
  1294. X
  1295. X
  1296. X
  1297. X
  1298. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  1299. X
  1300. X
  1301. X
  1302. X               be terminated by a dollar sign.  -P followed by a
  1303. X               string changes the default (short) prompt to that
  1304. X               string.  -Pm changes the medium (-m) prompt to the
  1305. X               string, and -PM changes the long (-M) prompt.  Also,
  1306. X               -P= changes the message printed by the = command to the
  1307. X               given string.  All prompt strings consist of a sequence
  1308. X               of letters and special escape sequences.  See the
  1309. X               section on PROMPTS for more details.
  1310. X
  1311. X          -q   Normally, if an attempt is made to scroll past the end
  1312. X               of the file or before the beginning of the file, the
  1313. X               terminal bell is rung to indicate this fact.  The -q
  1314. X               option tells _l_e_s_s not to ring the bell at such times.
  1315. X               If the terminal has a "visual bell", it is used
  1316. X               instead.
  1317. X
  1318. X          -Q   Even if -q is given, _l_e_s_s will ring the bell on certain
  1319. X               other errors, such as typing an invalid character.  The
  1320. X               -Q option tells _l_e_s_s to be quiet all the time; that is,
  1321. X               never ring the terminal bell.  If the terminal has a
  1322. X               "visual bell", it is used instead.
  1323. X
  1324. X          -s   The -s option causes consecutive blank lines to be
  1325. X               squeezed into a single blank line.  This is useful when
  1326. X               viewing _n_r_o_f_f output.
  1327. X
  1328. X          -t   The -t option, followed immediately by a TAG, will edit
  1329. X               the file containing that tag.  For this to work, there
  1330. X               must be a file called "tags" in the current directory,
  1331. X               which was previously built by the _c_t_a_g_s (1) command.
  1332. X               This option may also be specified from within less
  1333. X               (using the - command) as a way of examining a new file.
  1334. X
  1335. X          -u   If the -u option is given, backspaces are treated as
  1336. X               printable characters; that is, they are sent to the
  1337. X               terminal when they appear in the input.
  1338. X
  1339. X          -U   If the -U option is given, backspaces are printed as
  1340. X               the two character sequence "^H".
  1341. X
  1342. X               If neither -u nor -U is given, backspaces which appear
  1343. X               adjacent to an underscore character are treated
  1344. X               specially: the underlined text is displayed using the
  1345. X               terminal's hardware underlining capability.  Also,
  1346. X               backspaces which appear between two identical
  1347. X               characters are treated specially: the overstruck text
  1348. X               is printed using the terminal's hardware boldface
  1349. X               capability.  Other backspaces are deleted, along with
  1350. X               the preceeding character.
  1351. X
  1352. X          -w   Normally, _l_e_s_s uses a tilde character to represent
  1353. X               lines past the end of the file.  The -w option causes
  1354. X
  1355. X
  1356. X
  1357. X     Page 7                                          (printed 7/19/88)
  1358. X
  1359. X
  1360. X
  1361. X
  1362. X
  1363. X
  1364. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  1365. X
  1366. X
  1367. X
  1368. X               blank lines to be used instead.
  1369. X
  1370. X          -x   The -x_n option sets tab stops every _n positions.  The
  1371. X               default for _n is 8.
  1372. X
  1373. X          -[z] When given a backwards or forwards window command, _l_e_s_s
  1374. X               will by default scroll backwards or forwards one
  1375. X               screenful of lines. The -z_n option changes the default
  1376. X               scrolling window size to _n lines.  Note that the "z" is
  1377. X               optional for compatibility with _m_o_r_e.
  1378. X
  1379. X          +    If a command line option begins with ++++, the remainder
  1380. X               of that option is taken to be an initial command to
  1381. X               _l_e_s_s. For example, +G tells _l_e_s_s to start at the end of
  1382. X               the file rather than the beginning, and +/xyz tells it
  1383. X               to start at the first occurence of "xyz" in the file.
  1384. X               As a special case, +<number> acts like +<number>g; that
  1385. X               is, it starts the display at the specified line number
  1386. X               (however, see the caveat under the "g" command above).
  1387. X               If the option starts with ++++++++, the initial command
  1388. X               applies to every file being viewed, not just the first
  1389. X               one.  The + command described previously may also be
  1390. X               used to set (or change) an initial command for every
  1391. X               file.
  1392. X
  1393. X
  1394. X     KKKKEEEEYYYY BBBBIIIINNNNDDDDIIIINNNNGGGGSSSS
  1395. X          You may define your own less commands by using the program
  1396. X          _l_e_s_s_k_e_y (1) to create a file called ".less" in your home
  1397. X          directory.  This file specifies a set of command keys and an
  1398. X          action associated with each key.  See the _l_e_s_s_k_e_y manual
  1399. X          page for more details.
  1400. X
  1401. X
  1402. X     PPPPRRRROOOOMMMMPPPPTTTTSSSS
  1403. X          The -P option allows you to tailor the prompt to your
  1404. X          preference.  The string given to the -P option replaces the
  1405. X          specified prompt string.  Certain characters in the string
  1406. X          are interpreted specially.  The prompt mechanism is rather
  1407. X          complicated to provide flexibility, but the ordinary user
  1408. X          need not understand the details of constructing personalized
  1409. X          prompt strings.
  1410. X
  1411. X          A percent sign followed by a single character is expanded
  1412. X          according to what the following character is:
  1413. X
  1414. X          %bX  Replaced by the byte offset into the current input
  1415. X               file.  The b is followed by a single character (shown
  1416. X               as X above) which specifies the line whose byte offset
  1417. X               is to be used.  If the character is a "t", the byte
  1418. X               offset of the top line in the display is used, an "m"
  1419. X               means use the middle line, a "b" means use the bottom
  1420. X
  1421. X
  1422. X
  1423. X     Page 8                                          (printed 7/19/88)
  1424. X
  1425. X
  1426. X
  1427. X
  1428. X
  1429. X
  1430. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  1431. X
  1432. X
  1433. X
  1434. X               line, and a "B" means use the line just after the
  1435. X               bottom line.
  1436. X
  1437. X          %f   Replaced by the name of the current input file.
  1438. X
  1439. X          %i   Replaced by the index of the current file in the list
  1440. X               of input files.
  1441. X
  1442. X          %lX  Replaced by the line number of a line in the input
  1443. X               file.  The line to be used is determined by the X, as
  1444. X               with the %b option.
  1445. X
  1446. X          %m   Replaced by the total number of input files.
  1447. X
  1448. X          %pX  Replaced by the percent into the current input file.
  1449. X               The line used is determined by the X as with the %b
  1450. X               option.
  1451. X
  1452. X          %s   Replaced by the size of the current input file.
  1453. X
  1454. X          %t   Causes any trailing spaces to be removed.  Usually used
  1455. X               at the end of the string, but may appear anywhere.
  1456. X
  1457. X          %x   Replaced by the name of the next input file in the
  1458. X               list.
  1459. X
  1460. X          If any item is unknown (for example, the file size if input
  1461. X          is a pipe), a question mark is printed instead.
  1462. X
  1463. X          The format of the prompt string can be changed depending on
  1464. X          certain conditions.  A question mark followed by a single
  1465. X          character acts like an "IF": depending on the following
  1466. X          character, a condition is evaluated.  If the condition is
  1467. X          true, any characters following the question mark and
  1468. X          condition character, up to a period, are included in the
  1469. X          prompt.  If the condition is false, such characters are not
  1470. X          included.  A colon appearing between the question mark and
  1471. X          the period can be used to establish an "ELSE": any
  1472. X          characters between the colon and the period are included in
  1473. X          the string if and only if the IF condition is false.
  1474. X          Condition characters (which follow a question mark) may be:
  1475. X
  1476. X          ?a   True if any characters have been included in the prompt
  1477. X               so far.
  1478. X
  1479. X          ?bX  True if the byte offset of the specified line is known.
  1480. X
  1481. X          ?e   True if at end-of-file.
  1482. X
  1483. X          ?f   True if there is an input filename (that is, if input
  1484. X               is not a pipe).
  1485. X
  1486. X
  1487. X
  1488. X
  1489. X     Page 9                                          (printed 7/19/88)
  1490. X
  1491. X
  1492. X
  1493. X
  1494. X
  1495. X
  1496. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  1497. X
  1498. X
  1499. X
  1500. X          ?lX  True if the line number of the specified line is known.
  1501. X
  1502. X          ?m   True if there is more than one input file.
  1503. X
  1504. X          ?n   True if this is the first prompt in a new input file.
  1505. X
  1506. X          ?pX  True if the percent into the current input file of the
  1507. X               specified line is known.
  1508. X
  1509. X          ?s   True if the size of current input file is known.
  1510. X
  1511. X          ?x   True if there is a next input file (that is, if the
  1512. X               current input file is not the last one).
  1513. X
  1514. X          Any characters other than the special ones (question mark,
  1515. X          colon, period, percent, and backslash) become literally part
  1516. X          of the prompt.  Any of the special characters may be
  1517. X          included in the prompt literally by preceeding it with a
  1518. X          backslash.
  1519. X
  1520. X          Some examples:
  1521. X
  1522. X          ?f%f:Standard input.
  1523. X
  1524. X          This prompt prints the filename, if known; otherwise the
  1525. X          string "Standard input".
  1526. X
  1527. X          ?f%f .?ltLine %lt:?pt%pt:?btByte %bt:-...
  1528. X
  1529. X          This prompt would print the filename, if known.  The
  1530. X          filename is followed by the line number, if known, otherwise
  1531. X          the percent if known, otherwise the byte offset if known.
  1532. X          Otherwise, a dash is printed.  Notice how each question mark
  1533. X          has a matching period, and how the % after the %pt is
  1534. X          included literally by escaping it with a backslash.
  1535. X
  1536. X          ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t
  1537. X
  1538. X          This prints the filename if this is the first prompt in a
  1539. X          file, followed by the "file N of N" message if there is more
  1540. X          than one input file.  Then, if we are at end-of-file, the
  1541. X          string "(END)" is printed followed by the name of the next
  1542. X          file, if there is one.  Finally, any trailing spaces are
  1543. X          truncated.  This is the default prompt.  For reference, here
  1544. X          are the defaults for the other two prompts (-m and -M
  1545. X          respectively).  Each is broken into two lines here for
  1546. X          readability only.
  1547. X
  1548. X          ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x.:
  1549. X               ?pB%pB\%:byte %bB?s/%s...%t
  1550. X
  1551. X          ?f%f .?n?m(file %i of %m) ..?ltline %lt :byte %bB?s/%s ..
  1552. X
  1553. X
  1554. X
  1555. X     Page 10                                         (printed 7/19/88)
  1556. X
  1557. X
  1558. X
  1559. X
  1560. X
  1561. X
  1562. X     LLLLEEEESSSSSSSS((((1111))))                     UUUUNNNNIIIIXXXX 5555....0000                      LLLLEEEESSSSSSSS((((1111))))
  1563. X
  1564. X
  1565. X
  1566. X               ?e(END) ?x- Next\: %x.:?pB%pB\%..%t
  1567. X
  1568. X          And here is the default message produced by the = command:
  1569. X
  1570. X          ?f%f .?m(file %i of %m) .?ltline %lt .
  1571. X               byte %bB?s/%s. ?e(END) :?pB%pB\%..%t
  1572. X
  1573. X
  1574. X     SSSSEEEEEEEE AAAALLLLSSSSOOOO
  1575. X          lesskey(1)
  1576. X
  1577. X
  1578. X     WWWWAAAARRRRNNNNIIIINNNNGGGGSSSS
  1579. X          The = command and prompts (unless changed by -P) report the
  1580. X          line number of the line at the top of the screen, but the
  1581. X          byte and percent of the line at the bottom of the screen.
  1582. X
  1583. X
  1584. X
  1585. X
  1586. X
  1587. X
  1588. X
  1589. X
  1590. X
  1591. X
  1592. X
  1593. X
  1594. X
  1595. X
  1596. X
  1597. X
  1598. X
  1599. X
  1600. X
  1601. X
  1602. X
  1603. X
  1604. X
  1605. X
  1606. X
  1607. X
  1608. X
  1609. X
  1610. X
  1611. X
  1612. X
  1613. X
  1614. X
  1615. X
  1616. X
  1617. X
  1618. X
  1619. X
  1620. X
  1621. X     Page 11                                         (printed 7/19/88)
  1622. X
  1623. X
  1624. X
  1625. END_OF_FILE
  1626. echo shar: Extracting \"README\"
  1627. sed "s/^X//" >'README' <<'END_OF_FILE'
  1628. XThis is the distribution of "less", a paginator similar to "more" or "pg".
  1629. XThe manual page is in less.man (nroff source in less.nro).
  1630. X
  1631. XINSTALLATION:
  1632. X
  1633. X1. Move the distributed source to its own directory and 
  1634. X   unpack it by running "sh" on the distribution files,
  1635. X   if you have not already done so.
  1636. X
  1637. X2. Type "sh linstall" and answer the questions it asks.
  1638. X   This will generate a makefile and a defines.h.
  1639. X
  1640. X   If you choose not to include some features in your version,
  1641. X   you may wish to edit the manual page "less.nro" and the help
  1642. X   page "less.help" to remove the references to the appropriate 
  1643. X   commands or options.
  1644. X
  1645. X3. It is a good idea to look over the generated makefile 
  1646. X   and make sure it looks ok.
  1647. X
  1648. X4. Type "make" and watch the fun.
  1649. X
  1650. X5. If the make succeeds, it will generate a program "less"
  1651. X   in your current directory.  Test the generated program.
  1652. X
  1653. X6. When satisfied that it works, if you wish to install it
  1654. X   in a public place, type "make install".
  1655. X
  1656. XIf you have any problems building or running "less", 
  1657. Xsuggestions, complaints, etc., you may mail to the 
  1658. Xauthor via USENET at:
  1659. X    sun     \
  1660. X    decwrl      } !pyramid!ctnews!UNIX386!mark
  1661. X    hplabs   /
  1662. X
  1663. X
  1664. XNote to hackers: comments noting possible improvements are enclosed
  1665. Xin double curly brackets {{ like this }}.
  1666. END_OF_FILE
  1667. echo shar: Extracting \"less.help\"
  1668. sed "s/^X//" >'less.help' <<'END_OF_FILE'
  1669. X      Commands marked with * may be preceeded by a number, N.
  1670. X
  1671. X  H              Display this help.
  1672. X  q              Exit.
  1673. X
  1674. X  f, SPACE    *  Forward  N lines, default one screen.
  1675. X  b           *  Backward N lines, default one screen.
  1676. X  e, j, CR    *  Forward  N lines, default 1 line.
  1677. X  y, k        *  Backward N lines, default 1 line.
  1678. X  d           *  Forward  N lines, default half screen or last N to d/u.
  1679. X  u           *  Backward N lines, default half screen or last N to d/u.
  1680. X  r              Repaint screen.
  1681. X  R              Repaint screen, discarding buffered input.
  1682. X
  1683. X  /pattern    *  Search forward for N-th line containing the pattern.
  1684. X  ?pattern    *  Search backward for N-th line containing the pattern.
  1685. X  n           *  Repeat previous search (for N-th occurence).
  1686. X
  1687. X  g           *  Go to line N, default 1.
  1688. X  G           *  Like g, but default is last line in file.
  1689. X  p, %        *  Position to N percent into the file.
  1690. X  m<letter>      Mark the current position with <letter>.
  1691. X  '<letter>      Return to a previously marked position.
  1692. X  ''             Return to previous position.
  1693. X
  1694. X  E [file]       Examine a new file.
  1695. X  N           *  Examine the next file (from the command line).
  1696. X  P           *  Examine the previous file (from the command line).
  1697. X  =              Print current file name.
  1698. X  V              Print version number of "less".
  1699. X
  1700. X  -<flag>        Toggle a command line flag.
  1701. X  _<flag>        Display the setting of a command line flag.
  1702. X  +cmd           Execute the less cmd each time a new file is examined.
  1703. X
  1704. X  !command       Passes the command to the system to be executed (by $SHELL).
  1705. X  v              Edit the current file (with $EDITOR).
  1706. END_OF_FILE
  1707. echo shar: Extracting \"mkfuncs.awk\"
  1708. sed "s/^X//" >'mkfuncs.awk' <<'END_OF_FILE'
  1709. XBEGIN { FS="("; state = 0 }
  1710. X
  1711. X/^    public/ { ftype = $0; state = 1 }
  1712. X
  1713. X{ if (state == 1)
  1714. X    state = 2
  1715. X  else if (state == 2)
  1716. X    { print ftype,$1,"();"; state = 0 }
  1717. X}
  1718. END_OF_FILE
  1719.  
  1720.  
  1721.